using System.Drawing;
using System.Windows.Forms;
using Microsoft.Win32;

namespace Peepster.Core
{
    public static class AppSettings
    {
        private static readonly RegistryKey _startUpRegistryKey;

        static AppSettings()
        {
            _startUpRegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
        }

        public static HotKey GlobalHotKey { get; set; }

        public static bool RunOnWindowsStartUp
        {
            get { return _startUpRegistryKey.GetValue(Application.ProductName) != null; }
            set
            {
                if (value)
                    _startUpRegistryKey.SetValue(Application.ProductName, Application.ExecutablePath);
                else
                    _startUpRegistryKey.DeleteValue(Application.ProductName, false);
            }
        }

        public static string ClientName
        {
            get { return Properties.Settings.Default.ClientName; }
        }

        public static string ClientUrl
        {
            get { return Properties.Settings.Default.ClientUrl; }
        }

        public static string ConsumerKey
        {
            get { return Properties.Settings.Default.ConsumerKey; }
        }

        public static string ConsumerSecret
        {
            get { return Properties.Settings.Default.ConsumerSecret; }
        }

        public static string TwitterUserName
        {
            get { return Properties.Settings.Default.TwitterUserName; }
            set { Properties.Settings.Default.TwitterUserName = value; }
        }

        public static string TwitterPassword
        {
            get { return Properties.Settings.Default.TwitterPassword; }
            set { Properties.Settings.Default.TwitterPassword = value; }
        }

        public static Keys ShortCutKey
        {
            get { return Properties.Settings.Default.ShortCutKey; }
            set { Properties.Settings.Default.ShortCutKey = value; }
        }

        public static KeyModifiers ShortcutModifier
        {
            get { return Properties.Settings.Default.ShortcutModifier; }
            set {  Properties.Settings.Default.ShortcutModifier = value; }
        }

        public static Point InputViewStartLocation
        {
            get { return Properties.Settings.Default.InputViewLocation; }
            set { Properties.Settings.Default.InputViewLocation = value; }
        }

        public static TwitterServiceType TwitterServiceType
        {
            get { return Properties.Settings.Default.TwitterLib; }
        }

        public static void Save()
        {
            Properties.Settings.Default.Save();
            Properties.Settings.Default.Reload();
        }
    }
}